package aer.Por3oMas5;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Por3oMas5 {
	private static boolean si, b = true;
	private static BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));
	private static int numero, i, j;

	public static void main(String[] args) throws Exception {

		while (b) {
			programa();
		}

	}

	private static void programa() throws Exception {
		numero = Integer.parseInt(br.readLine());

		if (numero == 0)
			b = false;
		else if (numero == 1 || numero == 3 || numero == 6) {
			System.out.print("SI\n");
		} else if (numero < 6) {
			System.out.print("NO\n");
		} else {
			si = false;

			for (i = 1; i <= numero; i *= 3) {
				if (numero == i) {
					si = true;
					break;
				}
			}
			if (si) {
				System.out.print("SI\n");
			} else {
				i /= 3;

				for (j = 1; j <= i; j *= 3) {
					if ((numero - j) % 5 == 0) {
						si = true;
						break;
					}
				}

				if (si) {
					System.out.print("SI\n");
				} else {
					System.out.print("NO\n");
				}

			}
		}

	}
}